package com.tt.lcd.qunyangGPRS.chanfangActivity;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import com.tt.lcd.qunyangGPRS.R;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class CF_dangtian_info extends Activity {

	IntentFilter intf;

	ListView listView;

	private BroadcastReceiver br = new BroadcastReceiver() {

		@Override
		public void onReceive(Context context, Intent intent) {
			if(intent.getStringExtra("key2").equals("OK")){
				updata();
			}


		}
	};

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO 自动生成的方法存根
		super.onCreate(savedInstanceState);
		setContentView(R.layout.chanfang_dangtianinfo);

		intf = new IntentFilter("com.lcd.qydangtianRec");// 参数过滤器筛选条件，可以理解为广播名称
		registerReceiver(br, intf); // 注册广播


		listView = (ListView) this.findViewById(R.id.siweizhan_list);

//		Register.feedInfo.clear();
//		Toast.makeText(CF_dangtian_info.this, "执行查询，等待回复", 4).show();
//		Register.getRegister().server.send((byte)0x38);

		List<HashMap<String, Object>> data = new ArrayList<HashMap<String,Object>>();
		//获取到集合数据
		HashMap<String, Object> data1 = new HashMap<String, Object>();
		data1.put("zhanId", "1-2");
		data1.put("jihualiang", "8000");
		data1.put("caisiliang", "2000");
		data.add(data1);

		SimpleAdapter adapter = new SimpleAdapter(this, data,
				R.layout.chanfang_zhanlist, new String[] { "zhanId",
				"jihualiang","caisiliang" }, new int[] { R.id.zhanID,R.id.jihualiang,R.id.yicaisi
		});

		listView.setAdapter(adapter);

	}

	//更新显示
	public void updata(){
		// 获取到集合数据
//				List<HashMap<String, Object>> data = new DataManager()
//						.getNowFeedZhan();
//				SimpleAdapter adapter = new SimpleAdapter(this, data,
//						R.layout.chanfang_zhanlist, new String[] { "zhanId",
//								"jihualiang","caisiliang" }, new int[] { R.id.zhanID,R.id.jihualiang,R.id.yicaisi
//								 });
		// 实现列表的显示
//				listView.setAdapter(adapter);
	}



	@Override
	protected void onDestroy() {
		unregisterReceiver(br);
		super.onDestroy();
	}

}
